home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Serial.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  6KB  |  184 lines

  1. /*
  2.      File:        Serial.h
  3.  
  4.      Contains:    Asynchronous Serial Driver (.AIn/.AOut/.BIn/.BOut) Interfaces
  5.  
  6.      Version:    Technology:    System 7.5.2
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __SERIAL__
  19. #define __SERIAL__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. #if PRAGMA_IMPORT_SUPPORTED
  30. #pragma import on
  31. #endif
  32.  
  33. #if PRAGMA_ALIGN_SUPPORTED
  34. #pragma options align=mac68k
  35. #endif
  36.  
  37.  
  38. enum {
  39.     baud150                        = 763,
  40.     baud300                        = 380,
  41.     baud600                        = 189,
  42.     baud1200                    = 94,
  43.     baud1800                    = 62,
  44.     baud2400                    = 46,
  45.     baud3600                    = 30,
  46.     baud4800                    = 22,
  47.     baud7200                    = 14,
  48.     baud9600                    = 10,
  49.     baud14400                    = 6,
  50.     baud19200                    = 4,
  51.     baud28800                    = 2,
  52.     baud38400                    = 1,
  53.     baud57600                    = 0,
  54.     stop10                        = 16384,
  55.     stop15                        = -32768L,
  56.     stop20                        = -16384,
  57.     noParity                    = 0,
  58.     oddParity                    = 4096,
  59.     evenParity                    = 12288,
  60.     data5                        = 0,
  61.     data6                        = 2048,
  62.     data7                        = 1024,
  63.     data8                        = 3072
  64. };
  65.  
  66.  
  67. enum {
  68.     aData                        = 6,                            /* channel A data in or out (historical) */
  69.     aCtl                        = 2,                            /* channel A control (historical) */
  70.     bData                        = 4,                            /* channel B data in or out (historical) */
  71.     bCtl                        = 0,                            /* channel B control (historical) */
  72.     ctsEvent                    = 32,                            /* flag for SerShk.errs and SerShk.evts */
  73.     breakEvent                    = 128,                            /* flag for SerShk.errs and SerShk.evts */
  74.     xOffWasSent                    = 128,                            /* flag for SerStaRec.xOffSent */
  75.     dtrNegated                    = 64,                            /* flag for SerStaRec.xOffSent */
  76.     ainRefNum                    = -6,                            /* serial port A input */
  77.     aoutRefNum                    = -7,                            /* serial port A output */
  78.     binRefNum                    = -8,                            /* serial port B input */
  79.     boutRefNum                    = -9,                            /* serial port B output */
  80.     swOverrunErr                = 1,                            /* serial driver error masks */
  81.     breakErr                    = 8,                            /* serial driver error masks */
  82.     parityErr                    = 16,                            /* serial driver error masks */
  83.     hwOverrunErr                = 32,                            /* serial driver error masks */
  84.     framingErr                    = 64,                            /* serial driver error masks */
  85.     kOptionClockX1CTS            = 64,                            /* option bit used with Control code 16 */
  86.     kOptionPreserveDTR            = 128                            /* option bit used with Control code 16 */
  87. };
  88.  
  89.  
  90. enum {
  91.     sPortA                        = 0,
  92.     sPortB                        = 1
  93. };
  94.  
  95. typedef SInt8 SPortSel;
  96. /* csCodes for serial driver Control routines */
  97.  
  98. enum {
  99.     kSERDConfiguration            = 8,                            /* program port speed, bits/char, parity, and stop bits */
  100.     kSERDInputBuffer            = 9,                            /* set buffer for chars received with no read pending */
  101.     kSERDSerHShake                = 10,                            /* equivalent to SerHShake, largely obsolete */
  102.     kSERDClearBreak                = 11,                            /* assert break signal on output */
  103.     kSERDSetBreak                = 12,                            /* negate break state on output */
  104.     kSERDBaudRate                = 13,                            /* set explicit baud rate, other settings unchanged */
  105.     kSERDHandshake                = 14,                            /* superset of 10, honors setting of fDTR */
  106.     kSERDClockMIDI                = 15,                            /* clock externally on CTS with specified multiplier */
  107.     kSERDMiscOptions            = 16,                            /* select clock source and DTR behavior on close */
  108.     kSERDAssertDTR                = 17,                            /* assert DTR output */
  109.     kSERDNegateDTR                = 18,                            /* negate DTR output */
  110.     kSERDSetPEChar                = 19,                            /* select char to replace chars with invalid parity */
  111.     kSERDSetPEAltChar            = 20,                            /* select char to replace char that replaces chars with invalid parity */
  112.     kSERDSetXOffFlag            = 21,                            /* set XOff output flow control (same as receiving XOff) */
  113.     kSERDClearXOffFlag            = 22,                            /* clear XOff output flow control (same as receiving XOn) */
  114.     kSERDSendXOn                = 23,                            /* send XOn if input flow control state is XOff */
  115.     kSERDSendXOnOut                = 24,                            /* send XOn regardless of input flow control state */
  116.     kSERDSendXOff                = 25,                            /* send XOff if input flow control state is XOn */
  117.     kSERDSendXOffOut            = 26,                            /* send XOff regardless of input flow control state */
  118.     kSERDResetChannel            = 27,                            /* reset serial I/O channel hardware */
  119.     kSERD115KBaud                = 115,                            /* set 115.2K baud data rate (some driver versions) */
  120.     kSERD230KBaud                = 230                            /* set 230.4K baud data rate (some driver versions) */
  121. };
  122.  
  123. /* csCodes for serial driver Status routines */
  124.  
  125. enum {
  126.     kSERDInputCount                = 2,                            /* return characters available (SerGetBuf) */
  127.     kSERDStatus                    = 8,                            /* return characters available (SerStatus) */
  128.     kSERDVersion                = 9                                /* return version number in first byte of csParam */
  129. };
  130.  
  131. struct SerShk {
  132.     Byte                             fXOn;                        /* XOn flow control enabled flag */
  133.     Byte                             fCTS;                        /* CTS flow control enabled flag */
  134.     unsigned char                     xOn;                        /* XOn character */
  135.     unsigned char                     xOff;                        /* XOff character */
  136.     Byte                             errs;                        /* errors mask bits */
  137.     Byte                             evts;                        /* event enable mask bits */
  138.     Byte                             fInX;                        /* Input flow control enabled flag */
  139.     Byte                             fDTR;                        /* DTR input flow control flag */
  140. };
  141. typedef struct SerShk SerShk;
  142.  
  143. struct SerStaRec {
  144.     Byte                             cumErrs;                    /* errors accumulated since last SerStatus() call */
  145.     Byte                             xOffSent;                    /* input (requested to be) held off by xOffWasSent or dtrNegated */
  146.     Byte                             rdPend;                        /* incomplete read pending in I/O queue */
  147.     Byte                             wrPend;                        /* incomplete write pending in I/O queue */
  148.     Byte                             ctsHold;                    /* transmit disabled by hardware handshaking */
  149.     Byte                             xOffHold;                    /* transmit disabled by XOn/XOff handshaking */
  150. };
  151. typedef struct SerStaRec SerStaRec;
  152.  
  153. #if FOR_SYSTEM7_ONLY
  154. extern pascal OSErr SerReset(short refNum, short serConfig);
  155.  
  156. extern pascal OSErr SerSetBuf(short refNum, Ptr serBPtr, short serBLen);
  157.  
  158. extern pascal OSErr SerHShake(short refNum, const SerShk *flags);
  159.  
  160. extern pascal OSErr SerSetBrk(short refNum);
  161.  
  162. extern pascal OSErr SerClrBrk(short refNum);
  163.  
  164. extern pascal OSErr SerGetBuf(short refNum, long *count);
  165.  
  166. extern pascal OSErr SerStatus(short refNum, SerStaRec *serSta);
  167.  
  168. #endif
  169.  
  170. #if PRAGMA_ALIGN_SUPPORTED
  171. #pragma options align=reset
  172. #endif
  173.  
  174. #if PRAGMA_IMPORT_SUPPORTED
  175. #pragma import off
  176. #endif
  177.  
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181.  
  182. #endif /* __SERIAL__ */
  183.  
  184.